package com.nbsaas.boot.cms.rest.resource;

import com.nbsaas.boot.cms.api.apis.NewsApi;
import com.nbsaas.boot.cms.data.entity.News;
import com.nbsaas.boot.cms.api.domain.request.NewsRequest;
import com.nbsaas.boot.cms.api.domain.response.NewsResponse;
import com.nbsaas.boot.cms.api.domain.simple.NewsSimple;
import com.nbsaas.boot.cms.rest.convert.NewsSimpleConvert;
import com.nbsaas.boot.cms.rest.convert.NewsEntityConvert;
import com.nbsaas.boot.cms.rest.convert.NewsResponseConvert;
import com.nbsaas.boot.cms.data.repository.NewsRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   新闻-业务接口实现
*/
@Transactional
@Service
public class NewsResource extends BaseResource<News,NewsResponse, NewsSimple, NewsRequest>  implements NewsApi {

    @Resource
    private NewsRepository newsRepository;

    @Override
    public JpaRepositoryImplementation<News, Serializable> getJpaRepository() {
        return newsRepository;
    }

    @Override
    public Function<News, NewsSimple> getConvertSimple() {
        return new NewsSimpleConvert();
    }

    @Override
    public Function<NewsRequest, News> getConvertForm() {
        return new NewsEntityConvert();
    }

    @Override
    public Function<News, NewsResponse> getConvertResponse() {
        return new NewsResponseConvert();
    }




}


